from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
from selenium.webdriver.common.action_chains import ActionChains

driver = webdriver.Firefox()
driver.maximize_window()
url = 'file:///C:/Users/TEACHER/Desktop/NSD2405/html/drop.html'
driver.get(url)
action = ActionChains(driver)
# 源元素
src = driver.find_element(By.CSS_SELECTOR, '#div1')
# 目标元素
target = driver.find_element(By.CSS_SELECTOR, '#div2')
# 拖拽
sleep(3)
action.drag_and_drop(src, target).perform()
# 拖拽到指定的偏移量
sleep(3)
action.drag_and_drop_by_offset(src, 500,300).perform()

sleep(3)
driver.quit()